package com.ruoyi.project.system.personnel.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.notice.domain.Notice;
import com.ruoyi.project.system.personnel.domain.Info;
import com.ruoyi.project.system.personnel.service.IinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 人员信息  控制层
 * @author LHF
 */
@Controller
@RequestMapping("/system/info")
public class InfoController extends BaseController {

    @Autowired
    private IinfoService infoService;

    private String prefix = "system/personnel";

    @GetMapping()
    public String info() {
        return prefix + "/info";
    }


    /**
     * 根据条件查询所有人员信息
     *
     * @param userId
     * @param userName
     * @param sex
     * @param deptName
     * @param status
     * @return
     */
    @PostMapping("list")
    @ResponseBody
    public TableDataInfo infoList(String userId, String userName, Integer sex, String deptName, Integer status) {
        startPage();
        List<Info> infos = infoService.queryAllInfo(userId, userName, sex, deptName, status);
        return getDataTable(infos);
    }

    /**
     * 新增人员信息
     *
     * @return
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }


    /**
     * 新增保存人员信息
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Notice notice) {
//        return toAjax(noticeService.insertNotice(notice));
        return null;
    }


    /**
     * 修改人员信息
     */
    @GetMapping("/edit/{userId}")
    public String edit(@PathVariable("userId") Long userId, ModelMap mmap) {
//        mmap.put("notice", noticeService.selectNoticeById(noticeId));
        return prefix + "/edit";
    }


    /**
     * 修改保存人员信息
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Notice notice) {
//        return toAjax(noticeService.updateNotice(notice));
        return null;
    }


    /**
     * 删除人员信息
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids){
        return toAjax(infoService.deleteInfo(ids));
    }


}